<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">

    <title>登录页</title>
    <script src="../../jquery.min.js"></script>

    <script src="../../httpPath.js"></script>
    <script src="../../httpUtils.js?v1"></script>
    <script src="../../site.js"></script>

    <link rel="stylesheet" href="../../css/layui.css">
    <link rel="stylesheet" href="../../css/login.css">

</head>

<body class="">
    <!-- header -->
    <div class="layui-header">
        <div class="layui-logo">
            <div class="layui-logo-brand">
                <a href="#/manager/main"><img class="logo_blue" src="../../img/logo_blue.png" /><span>CSAA等级考试后台管理</span></a>
            </div>
        </div>
        <div class="layui-layout-left">
        </div>
        <div class="layui-layout-right">
            <ul class="kit-nav" lay-filter="header_right">

                <li class="kit-item">
                    <a class="layui-btn layui-btn-normal back_web" href="http://47.116.3.110:9601/csaa/CSAA_html/platform/cass_webview/index.html">
                    返回官网
                </a>
                </li>
            </ul>
        </div>
    </div>
    <div class="login-main">
        <header class="layui-elip">登录</header>
        <form class="layui-form">
            <div class="layui-input-inline">
                <input type="text" name="account" required lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-input-inline login-btn">
                <button type="button" class="layui-btn layui-btn-normal btn_submit">登录</button>
            </div>

        </form>
    </div>


    <script type="text/javascript">
        // 操作对象
        $(document).on("click", ".btn_submit", function() {
            //默认传时间戳
            var timestamp = (new Date()).getTime();
            var codeId = timestamp;

            var userName = $("[name=account]").val();
            var passWord = $("[name=password]").val();

            $.ajax({
                url: GET_LOGIN,
                //url: "./ok.json",
                data: {
                    roleCode: "superadmin",
                    codeId: codeId,
                    userName: userName,
                    passWord: passWord
                },
                dataType: 'json',
                type: 'post',
                timeout: 20000,
                success: function(data) {
                    if (data.status == 1) {
                        if (window.localStorage) {

                            localStorage.setItem("admin_token", data.data.token); //token
                            localStorage.setItem("admin_userName", data.data.userName); //账号
                        } else {

                            $.cookie("admin_token", data.data.token, {
                                expires: 700
                            });
                            $.cookie("admin_userName", data.data.userName, {
                                expires: 700
                            });
                        }

                        location.replace("../../index.html");
                        //window.location.href = "http://192.168.3.100/csaa/CSAA_html/manager-html/index.html#/manager/main"
                    } else {
                        alert(data.msg);
                    }
                }
            })
        });
        $(".login-main").keydown(function(e) {
            var e = e || event,
                keycode = e.which || e.keyCode;
            if (keycode == 13) {
                $(".btn_submit").trigger("click");
            }
        });
    </script>
</body>

</html>